package org.shj.basic;

public class ShutdownHook {

	public static void main(String[] args) {
		System.out.println("main: Begin");
		
		Runtime.getRuntime().addShutdownHook(new Thread(){
			public void run(){
				System.out.println("*********");
				System.out.println(Thread.currentThread().getName() + ": SHUTDOWN HOOK");
				System.out.println("*********");
			}
		});
		
		System.out.println("main:SLEEP...");
		
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("EXIT...");
		
		System.exit(0); //强制结束
		
		//不会执行到这里
		System.out.println("main:END");

	}

}
